<template>
  <div class="">
    <child
      v-for="(item, index) in list"
      :key="index"
      :item="item"
      @removes="removes"
    ></child>
  </div>
</template>

<script>
import child from "@/components/child.vue";
export default {
  data() {
    return {
      list: [],
    };
  },

  methods: {
    getdata() {
      this.$axios.get("goods.json").then((res) => {
        console.log(res);
        this.list = res.data;
      });
    },
    removes(id) {
      this.list.forEach((item, index) => {
        if (item._id == id) {
          this.list.splice(index, 1);
        }
      });
    },
  },
  mounted() {
    this.getdata();
  },

  components: {
    child,
  },
};
</script>

<style lang="scss"></style>
